package com.medicine.manage.service.impl;

import java.util.List;
import com.medicine.common.utils.DateUtils;
import com.medicine.common.utils.SecurityUtils;
import com.medicine.manage.block.service.IBlockProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.medicine.manage.mapper.OrderConfirmMapper;
import com.medicine.manage.domain.OrderConfirm;
import com.medicine.manage.service.IOrderConfirmService;

/**
 * 订单确认Service业务层处理
 * 
 * @author admin
 * @date 2024-10-13
 */
@Service
public class OrderConfirmServiceImpl implements IOrderConfirmService 
{
    @Autowired
    private OrderConfirmMapper orderConfirmMapper;

    @Autowired
    @Qualifier("blockProcessConfirmService")
    private IBlockProcessService blockProcessConfirmService;

    /**
     * 查询订单确认
     * 
     * @param id 订单确认主键
     * @return 订单确认
     */
    @Override
    public OrderConfirm selectOrderConfirmById(Long id)
    {
        return orderConfirmMapper.selectOrderConfirmById(id);
    }

    /**
     * 查询订单确认列表
     * 
     * @param orderConfirm 订单确认
     * @return 订单确认
     */
    @Override
    public List<OrderConfirm> selectOrderConfirmList(OrderConfirm orderConfirm)
    {
        return orderConfirmMapper.selectOrderConfirmList(orderConfirm);
    }

    /**
     * 新增订单确认
     * 
     * @param orderConfirm 订单确认
     * @return 结果
     */
    @Override
    public int insertOrderConfirm(OrderConfirm orderConfirm)
    {
        orderConfirm.setCreateBy(SecurityUtils.getLoginUser().getUserId().toString());
        orderConfirm.setCreateTime(DateUtils.getNowDate());
        int result = orderConfirmMapper.insertOrderConfirm(orderConfirm);
        blockProcessConfirmService.insertProcessObj(orderConfirm, SecurityUtils.getLoginUser().getDeptId(), SecurityUtils.getLoginUser().getUserId());
        return result;
    }

    /**
     * 修改订单确认
     * 
     * @param orderConfirm 订单确认
     * @return 结果
     */
    @Override
    public int updateOrderConfirm(OrderConfirm orderConfirm)
    {
        orderConfirm.setUpdateBy(SecurityUtils.getLoginUser().getUserId().toString());
        orderConfirm.setUpdateTime(DateUtils.getNowDate());
        int result = orderConfirmMapper.updateOrderConfirm(orderConfirm);
        OrderConfirm confirem = orderConfirmMapper.selectOrderConfirmById(orderConfirm.getId());
        blockProcessConfirmService.updateProcessObj(confirem, SecurityUtils.getLoginUser().getDeptId(), SecurityUtils.getLoginUser().getUserId());
        return result;
    }

    /**
     * 批量删除订单确认
     * 
     * @param ids 需要删除的订单确认主键
     * @return 结果
     */
    @Override
    public int deleteOrderConfirmByIds(Long[] ids)
    {
        return orderConfirmMapper.deleteOrderConfirmByIds(ids);
    }

    /**
     * 删除订单确认信息
     * 
     * @param id 订单确认主键
     * @return 结果
     */
    @Override
    public int deleteOrderConfirmById(Long id)
    {
        return orderConfirmMapper.deleteOrderConfirmById(id);
    }
}
